#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <queue>
using namespace std;
const int maxn = 2023;
const int maxm = 30010;
struct Trie {
    int fail;
    int son[2];
    int cnt;
    bool flag;
}a[maxm];
int cnt;
int n;
void inrt(string s) {
    int now = 0;
    for (int i = 0; i < s.length(); i++) {
        if (a[now].son[s[i] - '0'] == 0) {
            a[now].son[s[i] - '0'] = ++cnt;
        }
        now = a[now].son[s[i] - '0'];
    }
    a[now].cnt++;
    a[now].flag = true;
}
void bfail() {
    queue<int> q;
    for (int i = 0; i < 2; i++) {
        if (a[0].son[i]) {
            a[a[0].son[i]].fail = 0;
            q.push(a[0].son[i]);
        }
    }
    while (q.size()) {
        int u = q.front();
        q.pop();
        for (int i = 0; i < 2; i++) {
            if (a[u].son[i]) {
                a[a[u].son[i]].fail = a[a[u].fail].son[i];
                if (a[a[a[u].son[i]].fail].flag) a[a[u].son[i]].flag = true;
                q.push(a[u].son[i]);
            }
            else {
                a[u].son[i] = a[a[u].fail].son[i];
            }
        }
    }
}
bool vis[maxm];
bool route[maxm];
bool dfs(int o) {
    if (route[o]) {
        // cout << "find route " << o << endl;
        return true; // find a loop
    }
    if (vis[o]) return false;
    if (a[o].flag) return false; // dangerous node
    // cout << "enter " << o << endl;
    route[o] = true; vis[o] = true;
    if (dfs(a[o].son[0]) || dfs(a[o].son[1])) return true;
    route[o] = false;
    return false;
}
bool search() {
    return dfs(0);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string ins;
        cin >> ins;
        inrt(ins);
    }
    bfail();
    if (search()) cout << "TAK" << endl;
    else cout << "NIE" << endl;
    return 0;
}
